package com.esm.daoimpl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.esm.dao.UpdateRecordDao_zxk;
import com.esm.utils.JDBCUtil;
/**
 * 修改考勤记录 Dao实现
 * @author 康少
 *
 * 2017年1月4日
 */
public class UpdateRecordDaoimpl_zxk implements UpdateRecordDao_zxk{
	/**
	 * 修改加班记录
	 */
	public boolean updateOvertime(int att_id, int uid, String uname, String state, String time, String date, String remark) {
		// TODO Auto-generated method stub
		boolean flag = false;
		StringBuffer sql = new StringBuffer();
		sql.append(" UPDATE ems_attend");
		sql.append(" SET ems_attend.uid = ?,ems_attend.uname = ?,ems_attend.state_zxk = ?,");
		sql.append("ems_attend.time = ?,ems_attend.date = ?,ems_attend.remark = ?");
		sql.append(" WHERE ems_attend.att_id = ?");
		Connection con = JDBCUtil.getConnection();
		PreparedStatement pst = null;
		try {
			pst = con.prepareStatement(sql.toString());
			pst.setInt(1, uid);
			pst.setString(2, uname);
			pst.setString(3, state);
			pst.setString(4, time);
			pst.setString(5, date);
			pst.setString(6, remark);
			pst.setInt(7, att_id);
			int a = pst.executeUpdate();
			if (a > 0) {
				flag = true;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		JDBCUtil.closeJDBC(pst, con);
		return flag;
	}
	/**
	 * 修改出差记录
	 */
	public boolean updateBtravel(int att_id, int uid, String uname, String state, String time, String date,
			String remark) {
		// TODO Auto-generated method stub
		boolean flag = false;
		StringBuffer sql = new StringBuffer();
		sql.append(" UPDATE ems_attend");
		sql.append(" SET ems_attend.uid = ?,ems_attend.uname = ?,ems_attend.state_zxk = ?,");
		sql.append("ems_attend.time = ?,ems_attend.date = ?,ems_attend.remark = ?");
		sql.append(" WHERE ems_attend.att_id = ?");
		Connection con = JDBCUtil.getConnection();
		PreparedStatement pst = null;
		try {
			pst = con.prepareStatement(sql.toString());
			pst.setInt(1, uid);
			pst.setString(2, uname);
			pst.setString(3, state);
			pst.setString(4, time);
			pst.setString(5, date);
			pst.setString(6, remark);
			pst.setInt(7, att_id);
			int a = pst.executeUpdate();
			if (a > 0) {
				flag = true;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		JDBCUtil.closeJDBC(pst, con);
		return flag;
	}
	/**
	 * 修改请假记录
	 */
	public boolean updateLeavel(int att_id, int uid, String uname, String state, String time, String date,
			String remark) {
		// TODO Auto-generated method stub
		boolean flag = false;
		StringBuffer sql = new StringBuffer();
		sql.append(" UPDATE ems_attend");
		sql.append(" SET ems_attend.uid = ?,ems_attend.uname = ?,ems_attend.state_zxk = ?,");
		sql.append("ems_attend.time = ?,ems_attend.date = ?,ems_attend.remark = ?");
		sql.append(" WHERE ems_attend.att_id = ?");
		Connection con = JDBCUtil.getConnection();
		PreparedStatement pst = null;
		try {
			pst = con.prepareStatement(sql.toString());
			pst.setInt(1, uid);
			pst.setString(2, uname);
			pst.setString(3, state);
			pst.setString(4, time);
			pst.setString(5, date);
			pst.setString(6, remark);
			pst.setInt(7, att_id);
			int a = pst.executeUpdate();
			if (a > 0) {
				flag = true;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		JDBCUtil.closeJDBC(pst, con);
		return flag;
	}

}
